<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>libCZI: libCZI::ScopedBitmapLocker&lt; tBitmap &gt; Class Template Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(initResizable);
/* @license-end */</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script><script type="text/javascript" async src="http://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">libCZI
   </div>
   <div id="projectbrief">Reading CZI documents made easy</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('classlib_c_z_i_1_1_scoped_bitmap_locker.html','');});
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="classlib_c_z_i_1_1_scoped_bitmap_locker-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">libCZI::ScopedBitmapLocker&lt; tBitmap &gt; Class Template Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p><code>#include &lt;<a class="el" href="lib_c_z_i___pixels_8h_source.html">libCZI_Pixels.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for libCZI::ScopedBitmapLocker&lt; tBitmap &gt;:</div>
<div class="dyncontent">
 <div class="center">
  <img src="classlib_c_z_i_1_1_scoped_bitmap_locker.png" usemap="#libCZI::ScopedBitmapLocker_3C_20tBitmap_20_3E_map" alt=""/>
  <map id="libCZI::ScopedBitmapLocker_3C_20tBitmap_20_3E_map" name="libCZI::ScopedBitmapLocker_3C_20tBitmap_20_3E_map">
<area href="structlib_c_z_i_1_1_bitmap_lock_info.html" title="Information about a locked bitmap - allowing direct access to the image data in memory. " alt="libCZI::BitmapLockInfo" shape="rect" coords="0,0,235,24"/>
</map>
 </div></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a871926718a1b6f2b00002d327154049b"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlib_c_z_i_1_1_scoped_bitmap_locker.html#a871926718a1b6f2b00002d327154049b">ScopedBitmapLocker</a> (tBitmap bmData)</td></tr>
<tr class="separator:a871926718a1b6f2b00002d327154049b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3d5e197884453daaa5c6252a6dd19e9e"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlib_c_z_i_1_1_scoped_bitmap_locker.html#a3d5e197884453daaa5c6252a6dd19e9e">ScopedBitmapLocker</a> (const <a class="el" href="classlib_c_z_i_1_1_scoped_bitmap_locker.html">ScopedBitmapLocker</a>&lt; tBitmap &gt; &amp;other)</td></tr>
<tr class="separator:a3d5e197884453daaa5c6252a6dd19e9e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae8096865753018bffff4544c28ab4945"><td class="memItemLeft" align="right" valign="top"><a id="ae8096865753018bffff4544c28ab4945"></a>
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlib_c_z_i_1_1_scoped_bitmap_locker.html#ae8096865753018bffff4544c28ab4945">ScopedBitmapLocker</a> (<a class="el" href="classlib_c_z_i_1_1_scoped_bitmap_locker.html">ScopedBitmapLocker</a>&lt; tBitmap &gt; &amp;&amp;other) noexcept</td></tr>
<tr class="memdesc:ae8096865753018bffff4544c28ab4945"><td class="mdescLeft">&#160;</td><td class="mdescRight">move constructor <br /></td></tr>
<tr class="separator:ae8096865753018bffff4544c28ab4945"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aaaf38bc85de0190783597ccf3620fd85"><td class="memItemLeft" align="right" valign="top"><a id="aaaf38bc85de0190783597ccf3620fd85"></a>
<a class="el" href="classlib_c_z_i_1_1_scoped_bitmap_locker.html">ScopedBitmapLocker</a>&lt; tBitmap &gt; &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlib_c_z_i_1_1_scoped_bitmap_locker.html#aaaf38bc85de0190783597ccf3620fd85">operator=</a> (<a class="el" href="classlib_c_z_i_1_1_scoped_bitmap_locker.html">ScopedBitmapLocker</a>&lt; tBitmap &gt; &amp;&amp;other) noexcept</td></tr>
<tr class="memdesc:aaaf38bc85de0190783597ccf3620fd85"><td class="mdescLeft">&#160;</td><td class="mdescRight">move assignment <br /></td></tr>
<tr class="separator:aaaf38bc85de0190783597ccf3620fd85"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="inherited"></a>
Additional Inherited Members</h2></td></tr>
<tr class="inherit_header pub_attribs_structlib_c_z_i_1_1_bitmap_lock_info"><td colspan="2" onclick="javascript:toggleInherit('pub_attribs_structlib_c_z_i_1_1_bitmap_lock_info')"><img src="closed.png" alt="-"/>&#160;Public Attributes inherited from <a class="el" href="structlib_c_z_i_1_1_bitmap_lock_info.html">libCZI::BitmapLockInfo</a></td></tr>
<tr class="memitem:a1113106a82231213cd4e8980d3106ebd inherit pub_attribs_structlib_c_z_i_1_1_bitmap_lock_info"><td class="memItemLeft" align="right" valign="top"><a id="a1113106a82231213cd4e8980d3106ebd"></a>
void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structlib_c_z_i_1_1_bitmap_lock_info.html#a1113106a82231213cd4e8980d3106ebd">ptrData</a></td></tr>
<tr class="memdesc:a1113106a82231213cd4e8980d3106ebd inherit pub_attribs_structlib_c_z_i_1_1_bitmap_lock_info"><td class="mdescLeft">&#160;</td><td class="mdescRight">Not currently used, to be ignored. <br /></td></tr>
<tr class="separator:a1113106a82231213cd4e8980d3106ebd inherit pub_attribs_structlib_c_z_i_1_1_bitmap_lock_info"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab54e2118992996eacc9ccd8e49397f09 inherit pub_attribs_structlib_c_z_i_1_1_bitmap_lock_info"><td class="memItemLeft" align="right" valign="top"><a id="ab54e2118992996eacc9ccd8e49397f09"></a>
void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structlib_c_z_i_1_1_bitmap_lock_info.html#ab54e2118992996eacc9ccd8e49397f09">ptrDataRoi</a></td></tr>
<tr class="memdesc:ab54e2118992996eacc9ccd8e49397f09 inherit pub_attribs_structlib_c_z_i_1_1_bitmap_lock_info"><td class="mdescLeft">&#160;</td><td class="mdescRight">The pointer to the first (top-left) pixel of the bitmap. <br /></td></tr>
<tr class="separator:ab54e2118992996eacc9ccd8e49397f09 inherit pub_attribs_structlib_c_z_i_1_1_bitmap_lock_info"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8e7259142382ec0ad887c974d27775b6 inherit pub_attribs_structlib_c_z_i_1_1_bitmap_lock_info"><td class="memItemLeft" align="right" valign="top"><a id="a8e7259142382ec0ad887c974d27775b6"></a>
std::uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structlib_c_z_i_1_1_bitmap_lock_info.html#a8e7259142382ec0ad887c974d27775b6">stride</a></td></tr>
<tr class="memdesc:a8e7259142382ec0ad887c974d27775b6 inherit pub_attribs_structlib_c_z_i_1_1_bitmap_lock_info"><td class="mdescLeft">&#160;</td><td class="mdescRight">The stride of the bitmap data (pointed to by <code>ptrDataRoi</code>). <br /></td></tr>
<tr class="separator:a8e7259142382ec0ad887c974d27775b6 inherit pub_attribs_structlib_c_z_i_1_1_bitmap_lock_info"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a109f8d69b48bc4398861217c375dee1b inherit pub_attribs_structlib_c_z_i_1_1_bitmap_lock_info"><td class="memItemLeft" align="right" valign="top"><a id="a109f8d69b48bc4398861217c375dee1b"></a>
std::uint64_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structlib_c_z_i_1_1_bitmap_lock_info.html#a109f8d69b48bc4398861217c375dee1b">size</a></td></tr>
<tr class="memdesc:a109f8d69b48bc4398861217c375dee1b inherit pub_attribs_structlib_c_z_i_1_1_bitmap_lock_info"><td class="mdescLeft">&#160;</td><td class="mdescRight">The size of the bitmap data (pointed to by <code>ptrDataRoi</code>) in bytes. <br /></td></tr>
<tr class="separator:a109f8d69b48bc4398861217c375dee1b inherit pub_attribs_structlib_c_z_i_1_1_bitmap_lock_info"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><h3>template&lt;typename tBitmap&gt;<br />
class libCZI::ScopedBitmapLocker&lt; tBitmap &gt;</h3>

<p>A helper class used to scope the lock state of a bitmap.</p>
<p>It is intended to be used like this: </p><div class="fragment"><div class="line"><a class="code" href="classlib_c_z_i_1_1_i_bitmap_data.html">libCZI::IBitmapData</a>* bm = ... <span class="comment">// assume that we have a pointer to a bitmap</span></div><div class="line"></div><div class="line"><span class="comment">// this example assumes that the pixel type is Gray8 and nothing else...</span></div><div class="line"><span class="keywordflow">if</span> (bm-&gt;<a class="code" href="classlib_c_z_i_1_1_i_bitmap_data.html#a66f27266674d7f328dd5f1270b81a94e">GetPixelType</a>() != <a class="code" href="namespacelib_c_z_i.html#abf8ce12ab88b06c8b3b47efbb5e2e834ac8cfe3d00282445878661f32adca48ef">libCZI::PixelType::Gray8</a>) <span class="keywordflow">throw</span> std::exception();</div><div class="line"></div><div class="line">{</div><div class="line">    <span class="comment">// access the bitmap&#39;s pixels directly within this scope</span></div><div class="line">    <a class="code" href="classlib_c_z_i_1_1_scoped_bitmap_locker.html">libCZI::ScopedBitmapLocker&lt;libCZI::IBitmapData*&gt;</a> lckBm{ bm };   <span class="comment">// &lt;- will call bm-&gt;Lock here</span></div><div class="line">    <span class="keywordflow">for</span> (std::uint32_t y  = 0; y &lt; bm-&gt;<a class="code" href="classlib_c_z_i_1_1_i_bitmap_data.html#a2072b5c8db493b7b19717811a96a6483">GetHeight</a>(); ++y)</div><div class="line">    {</div><div class="line">        <span class="keyword">const</span> std::uint8_t* ptrLine = ((<span class="keyword">const</span> std::uint8_t*)lckBm.ptrDataRoi) + y * lckBm.stride;</div><div class="line">        <span class="keywordflow">for</span> (std::uint32_t x  = 0; x &lt; bm-&gt;<a class="code" href="classlib_c_z_i_1_1_i_bitmap_data.html#aa2638991a88c736ff4e6c42dc4c6c5c7">GetWidth</a>(); ++x)</div><div class="line">        {</div><div class="line">            <span class="keyword">auto</span> pixelVal = ptrLine[x];</div><div class="line">            <span class="comment">// do something with the pixel...</span></div><div class="line">        }</div><div class="line">    }</div><div class="line">    </div><div class="line">    <span class="comment">// when lckBm goes out of scope, bm-&gt;Unlock will be called</span></div><div class="line"> }</div></div><!-- fragment --><p>For convenience two typedef are provided: <code>ScopedBitmapLockerP</code> and <code>ScopedBitmapLockerSP</code> for use with the types <code>IBitmapData*</code> and <code>std::shared_ptr&lt;<a class="el" href="classlib_c_z_i_1_1_i_bitmap_data.html">IBitmapData</a>&gt;</code>.</p>
<div class="fragment"><div class="line"><span class="keyword">typedef</span> ScopedBitmapLocker&lt;IBitmapData*&gt; <a class="code" href="namespacelib_c_z_i.html#aa0a4df11f476d960267cc3757d7e889d">ScopedBitmapLockerP</a>;</div><div class="line"><span class="keyword">typedef</span> ScopedBitmapLocker&lt;std::shared_ptr&lt;IBitmapData&gt;&gt; <a class="code" href="namespacelib_c_z_i.html#a44eca12300534095278df46d8b7ef824">ScopedBitmapLockerSP</a>;</div></div><!-- fragment --><p>So in above sample we could have used </p><div class="fragment"><div class="line"><a class="code" href="classlib_c_z_i_1_1_scoped_bitmap_locker.html">libCZI::ScopedBitmapLockerP</a> lckBm{ bm };</div></div><!-- fragment --><p>This utility is intended to help adhering to the RAII-pattern, since it makes writing exception-safe code easier - in case of an exception (within the scope of the <a class="el" href="classlib_c_z_i_1_1_scoped_bitmap_locker.html">ScopedBitmapLocker</a> object) the bitmap's Unlock method will be called (which is cumbersome to achieve otherwise). </p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a871926718a1b6f2b00002d327154049b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a871926718a1b6f2b00002d327154049b">&#9670;&nbsp;</a></span>ScopedBitmapLocker() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename tBitmap&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classlib_c_z_i_1_1_scoped_bitmap_locker.html">libCZI::ScopedBitmapLocker</a>&lt; tBitmap &gt;::<a class="el" href="classlib_c_z_i_1_1_scoped_bitmap_locker.html">ScopedBitmapLocker</a> </td>
          <td>(</td>
          <td class="paramtype">tBitmap&#160;</td>
          <td class="paramname"><em>bmData</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">explicit</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Constructor taking the object for which we provide the scope-guard. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">bmData</td><td>The object for which we are to provide the scope-guard. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a3d5e197884453daaa5c6252a6dd19e9e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3d5e197884453daaa5c6252a6dd19e9e">&#9670;&nbsp;</a></span>ScopedBitmapLocker() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename tBitmap&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classlib_c_z_i_1_1_scoped_bitmap_locker.html">libCZI::ScopedBitmapLocker</a>&lt; tBitmap &gt;::<a class="el" href="classlib_c_z_i_1_1_scoped_bitmap_locker.html">ScopedBitmapLocker</a> </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classlib_c_z_i_1_1_scoped_bitmap_locker.html">ScopedBitmapLocker</a>&lt; tBitmap &gt; &amp;&#160;</td>
          <td class="paramname"><em>other</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Copy-Constructor . </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">other</td><td>The other object. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>libCZI/<a class="el" href="lib_c_z_i___pixels_8h_source.html">libCZI_Pixels.h</a></li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="namespacelib_c_z_i.html">libCZI</a></li><li class="navelem"><a class="el" href="classlib_c_z_i_1_1_scoped_bitmap_locker.html">ScopedBitmapLocker</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.14 </li>
  </ul>
</div>
</body>
</html>
